<template>
  <view class="container">
    <!-- 用户信息 -->
    <view class="user-info">
      <image class="avatar" src="/static/my/avatar.jpg" />
      <view class="user-details">
        <view class="username">佳佳谈</view>
        <view class="stats">
          <text>22 关注</text> | <text>160 粉丝</text>
        </view>
      </view>
      <navigator class="settings" url="/pagesMember/settings/settings" hover-class="none">
        编辑个人资料
      </navigator>
    </view>

    <!-- 我的服务 -->
    <view class="services">
      <view class="service-item" v-for="(service, index) in services" :key="index">
        <button class="service-button" @click="goToService(service.name)">
          <image :src="service.icon" class="service-icon" />
        </button>
        <view class="service-name">{{ service.name }}</view>
      </view>
    </view>

    <!-- 退出登录按钮 -->
    <button class="logout-button" @click="logout">退出登录</button>
  </view>
</template>

<script>
import { removeToken } from '../../../store/token';
export default {
  data() {
    return {
      services: [
        { name: '我的订单', icon: '/static/my/order.png' },
        { name: '待付款', icon: '/static/my/pay.png' },
        { name: '待发货', icon: '/static/my/deliver.png' },
        { name: '待收货', icon: '/static/my/receive.png' },
        { name: '待评价', icon: '/static/my/review.png' },
        { name: '退款售后', icon: '/static/my/favorite.png' }
      ]
    };
  },
  methods: {
    goToService(serviceName) {
      uni.navigateTo({
        url: `/pages/serviceDetail/serviceDetail?service=${serviceName}`
      });
    },
    logout() {
      // 处理退出登录逻辑并跳转到登录页面
      console.log('退出登录');
			removeToken()
      uni.navigateTo({
        url: '/pages/login/login'
      });
    }
  }
};
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: #f5f5f5;
  min-height: 100vh;
}

.user-info {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  margin-bottom: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  position: relative;
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid #ffd700;
}

.user-details {
  flex: 1;
  margin-left: 20px;
}

.username {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.stats {
  color: #999;
}
.service-button {
  background-color: #ffd700;
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 20px;
  font-weight: bold;
  margin-top: 10px;
}
.services {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  background-color: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20%;
  margin: 10px 1%;
  background-color: #f9f9f9;
  border-radius: 10px;
  padding: 10px;
  transition: background-color 0.3s;
}

.service-item:hover {
  background-color: #f0f0f0;
}

.service-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
}

.service-name {
  font-size: 14px;
  color: #666;
}

.service-button {
  background-color: transparent;
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.logout-button {
  width: 80%;
  background-color: #ff4d4f;
  color: #fff;
  border: none;
  padding: 6px;
  border-radius: 20px;
  font-weight: bold;
  margin-top: 120px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
</style>
